// 格式化车险表格 值数据格式化
export default (ctx, next) =>{
    let resData = ctx.params;

    resData.forEach((item, index) =>{
        formatTime(item);
        formatValue(item);
    })

    next()    
    
}

// 值格式化(四舍五入, 取三位小数)
function formatValue (order:carTableOrder){
    let keys:string[] = ['vehicleEngineCapacity' ,'syAmount', 'jqAmount', 'vehicleWeight', 'vehicleWeight', 'vehiclePrice', 'vehicleTaxAmount'];

    keys.forEach(key =>{
        order[key] = Math.round(order[key]*1000)/1000;
    })
    
}

// 时间格式化
function formatTime (order:carTableOrder){
    let keys:string[] = ['createAt', 'updateAt', 'registerDate'];

    keys.forEach(key =>{
        order[key] = order[key].split('T')[0];
    })
    
}
